package com.mes.task.domain;


import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.JoinColumnOrFormula;
import org.hibernate.annotations.JoinColumnsOrFormulas;
import org.hibernate.annotations.JoinFormula;
import org.springframework.context.annotation.Lazy;

import com.mes.basicdata.domain.Part;
import com.mes.basicdata.domain.TypesData;
import com.mes.common.domain.BasicModel;

/**
 * <p>
 * author lcs
 * data 2017-03-26
 * </p>
 */
@Entity()
//@org.hibernate.annotations.Entity(dynamicInsert=true,dynamicUpdate=true)
@Table(name = "T_DEMAND_PART")
@BatchSize(size=20)
@Lazy(value=true)
//@Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class DemandPart extends BasicModel {
	
	@Id
	@GenericGenerator(name = "demandPartUid", strategy = "assigned")
	@Column(name="UNIQUEID")
	private String demandPartUid;
	
	
//	private TdemandPartId id;
	
	@Column(name="DEMANDUID")
	private String demandUid;
	/**
	 * ���Ӷ���ӳ��--demand
	 */
	//many-to-one
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="DEMANDUID",insertable=false,updatable=false)
	protected Demand demand;
	
	@Column(name="PART_NUMBER")
	private String partUid;
	/**
	 * ���Ӷ���ӳ��--part
	 */
	//many-to-one
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="PART_NUMBER",insertable=false,updatable=false)
	protected Part part;
	
	@Column(name="QTYREQ",precision=25,scale=6)
	private Double qtyReq;
	/**
	 * ������״̬ӳ��--reqtype
	 */
	@Column(name="REQTYPE",precision=10,scale=6)
	private Long reqType;
	
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumnsOrFormulas(value={
			@JoinColumnOrFormula(column=@JoinColumn(name="REQTYPE",referencedColumnName="ID",nullable=true,insertable=false,updatable=false)),
			@JoinColumnOrFormula(formula=@JoinFormula(value="'reqtype'", referencedColumnName="TYPESNAME"))
	})
	protected TypesData reqTypeDesc;
	
	/**
	 * ����״̬
	 */
	@Column(name="LOCKLEVEL",length=10)
	protected Long lockLevel;
	
	@Column(name="ALLOCATEDQTY",precision=25,scale=6)
	private Double allocatedQty;
	
	@Column(name="ISCRITICAL",length=10)
	protected Long isCritical;

	@Column(name="READYPOINT",precision=2,scale=0)
	protected Long readyPoint;
	
public Long getIsCritical() {
		return isCritical;
	}

	public void setIsCritical(Long isCritical) {
		this.isCritical = isCritical;
	}

	public Long getReadyPoint() {
		return readyPoint;
	}

	public void setReadyPoint(Long readyPoint) {
		this.readyPoint = readyPoint;
	}

	//	private Long isineffect;
//	private String creatorUid;
	/**
	 * ���Ӷ���ӳ��--creator
	 */
//	protected Employee creator;

	public String getDemandPartUid() {
		return demandPartUid;
	}

	public void setDemandPartUid(String demandPartUid) {
		this.demandPartUid = demandPartUid;
	}

	@Override
	public String getUuid() {
		// TODO Auto-generated method stub
		return this.demandPartUid;
	}

	@Override
	public void setUuid(String uuid) {
		// TODO Auto-generated method stub
		this.demandPartUid=uuid;
	}

	public String getDemandUid() {
		return demandUid;
	}

	public void setDemandUid(String demandUid) {
		this.demandUid = demandUid;
	}

	public Demand getDemand() {
		return demand;
	}

	public void setDemand(Demand demand) {
		this.demand = demand;
	}

	public String getPartUid() {
		return partUid;
	}

	public void setPartUid(String partUid) {
		this.partUid = partUid;
	}

	public Part getPart() {
		return part;
	}

	public void setPart(Part part) {
		this.part = part;
	}

	public Double getQtyReq() {
		return qtyReq;
	}

	public void setQtyReq(Double qtyReq) {
		this.qtyReq = qtyReq;
	}

	public Long getReqType() {
		return reqType;
	}

	public void setReqType(Long reqType) {
		this.reqType = reqType;
	}

	public TypesData getReqTypeDesc() {
		return reqTypeDesc;
	}

	public void setReqTypeDesc(TypesData reqTypeDesc) {
		this.reqTypeDesc = reqTypeDesc;
	}

	public Double getAllocatedQty() {
		return allocatedQty;
	}

	public void setAllocatedQty(Double allocatedQty) {
		this.allocatedQty = allocatedQty;
	}

	public Long getLockLevel() {
		return lockLevel;
	}

	public void setLockLevel(Long lockLevel) {
		this.lockLevel = lockLevel;
	}
	
	

	
}
